<?php

use h1cms\H1;
?>
<div class="sidebar">

    <nav class="sidebar-nav">
        <ul class="nav">            
            <?php
            $cur_module_name = module_name();
            $action = LG::get('lg_call_action_name');
            $request_uri = H1::$app->req->server('REQUEST_URI');
            $page_name = basename(H1::$app->req->server('SCRIPT_NAME'), '.php');
            foreach (H1::$app->screen->menus as $module_name => $menu) {
                ?>
                <li class="nav-item nav-dropdown <?php echo value_condition($cur_module_name == $module_name, 'open'); ?>">
                    <a href="<?php echo get_default($menu['link'], '#'); ?>" class="nav-link <?php if (is_array($menu['submenu'])) { echo 'nav-dropdown-toggle';} ?>">
                        <i class="<?php echo $menu['icon']; ?>"></i><?php echo $menu['label']; ?>                            
                    </a>
                    <?php if (is_array($menu['submenu'])) { ?>
                        <ul class="nav-dropdown-items">
                            <?php
                            foreach ($menu['submenu'] as $sub_menu) {
                                $perm = 'admin.menu.' . $cur_module_name . '.' . $page_name . '.' . $action;
                                ?>
                                <li class="nav-item<?php
                                if ($request_uri == $sub_menu['link'] || $perm == $sub_menu['permission']) {
                                    echo ' active ';
                                }
                                ?>" >
                                    <a class="nav-link" href="<?php echo $sub_menu['link']; ?>" > <i class="fa fa-angle-double-right"></i><?php echo $sub_menu['label']; ?></a>
                                </li>
                        <?php } ?>                          
                        </ul>
                <?php } ?>
                </li>
            <?php } ?>
                <li class="nav-title">
                        
                    </li>
        </ul>
    </nav>
</div>


